const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const  DllReferencePlugin = require('webpack/lib/DllReferencePlugin');
module.exports = {
    mode:'development',
    devtool:"source-map",
    context:__dirname,//如果给了context,那么所有的相对路径都是相于context,
   /*  entry:{
        entry1:"./src/entry1.js",
        entry2:"./src/entry2.js"
    }, */
    entry:'./src/index.js',
    output:{
        path:path.resolve(__dirname,'dist'),
        filename:'[name].js'
    },
    devServer:{
        hot:true
    },
    module:{
        rules:[
            {
                test: /\.jsx?$/,
                use: {
                    loader: 'babel-loader',
                    options:{
                    "presets": [["@babel/preset-env",{modules:false}],"@babel/preset-react"],
                    "plugins": [
                        ["@babel/plugin-proposal-decorators", { "legacy": true }],
                        ["@babel/plugin-proposal-class-properties", { "loose" : true }]
                    ]
                    }
                },
                include: path.join(__dirname,'src'),
                exclude:/node_modules/
            },
             {
                test:/\.css/,
                use:[
                    'style-loader',
                    'css-loader',
                    {
                        loader:'pr2rem-loader',
                        options:{
                            remUnit:75,
                            remPrecesion:8
                        }
                    }
                ]
            }
        ]
    },
    plugins:[
        new webpack.HotModuleReplacementPlugin(),
        new HtmlWebpackPlugin({
            template:'./src/index.html'
        }),
       /*  new DllReferencePlugin({
            manifest:path.resolve(__dirname,'dist','react.manifest.json')
        }) */
    ]
}